﻿using NUnit.Framework;
using Present.Commands.Fluent;

namespace Present.Commands.Tests.Fluent
{
    [TestFixture]
    public class DelegateCommandBuilderTestCase : TestCase
    {

        [Test]
        public void CanExecuteIsTrueIfNotSet()
        {
            Assert.IsTrue(Command.FromDelegates<int?>().ToCommand().CanExecute(1));
        }

        [Test]
        public void CanExecuteIsUsed()
        {
            Assert.IsFalse(Command.FromDelegates<int?>().CanExecuteIf(x => false).ToCommand().CanExecute(1));
        }

        [Test]
        public void Execute()
        {
            bool wasCalled = false;
           Command.FromDelegates<int?>().Execute(x => wasCalled = true).ToCommand().Execute(1);
            Assert.IsTrue(wasCalled);
        }
    }
}